<!--
 * @Author: your name
 * @Date: 2020-12-08 13:32:28
 * @LastEditTime: 2021-04-29 23:23:44
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /medicine-web/src/layout/index.vue
-->
<template>
  <div class="auth-container">
    <router-view></router-view>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import { setCookie } from '@/utils/auth.js'
export default {
  name: 'Layout',
  components: {},
  computed: {},
  methods: {
    getQueryVariable(variable) {
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if(pair[0] == variable){return pair[1];}
      }
      return false;
    }
  },
  created() {
    // const state = '7cce2563381e2cdf9b775439a271833f';
    // console.log('code======params', this.getQueryVariable('code'))
    // if (this.getQueryVariable('code') == false) {
    //   window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3c14646ee2420a3f&redirect_uri=${encodeURIComponent('http://video.xgichina.net/')}&response_type=code&scope=snsapi_base&state=${state}#wechat_redirect`;
    // } else {
    //   if (this.getQueryVariable('state') == state) {
    //     this.$action('wechatLogin', { code: this.getQueryVariable('code'), state: this.getQueryVariable('state') }).then((res) => {
    //       setCookie('openid', res.data.openid)
    //       this.$router.push('/main')
    //     });
    //   }
    // }
    // this.$action('wechatLogin', { code: '041P9Ukl2s2bR84a5inl2cO4n64P9Ukd', state }).then((res) => {
    //   console.log('wechatLogin===============', res);
    //   setCookie('openid', 'odglT6GJE2ciZ4NZNKCxHU9euLCY')
    //   this.$router.push('/main')
    // });
  }
}
</script>

<style lang="scss">
</style>
